<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2" />
    <g:set var="entityName" value="${message(code: 'opportunity.label', default: 'Opportunity')}" />
    <title>编辑商机</title>
</head>

<body>
    <div class="main-body">
        <div class="page-wrapper">
            <!-- Page-header start -->
            <div class="page-header">
                <div class="page-header-title">
                    <h4>编辑商机</h4>
                </div>

                <div class="page-header-breadcrumb">
                    <ul class="breadcrumb-title">
                        <li class="breadcrumb-item">
                            <a href="/salesDashboard/index">
                                <i class="icofont icofont-home"></i>
                            </a>
                        </li>
                        <li class="breadcrumb-item">
                            <g:link controller="opportunity" action="index">商机列表</g:link>
                        </li>
                        <li class="breadcrumb-item">编辑商机</li>
                    </ul>
                </div>
            </div>
            <!-- Page-header end -->
            <!-- Page-body start -->
            <div class="page-body">
                <g:if test="${flash.message}">
                    <div class="message alert alert-info" role="status">${flash.message}
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">×</span></button>
                    </div>
                </g:if>
                <g:hasErrors bean="${this.opportunity}">
                    <ul class="errors" role="alert">
                        <g:eachError bean="${this.opportunity}" var="error">
                            <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                                <g:message error="${error}" />
                            </li>
                        </g:eachError>
                    </ul>
                </g:hasErrors>
                <!-- Hover table card start -->
                <div class="card">
                    <div class="card-header">
                        <h5>编辑商机</h5>

                        <div class="card-header-right">
                            <i class="icofont icofont-rounded-down"></i>
                        </div>
                    </div>

                    <div class="card-block">
                        <g:form resource="${this.opportunity}" method="PUT">
                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">商机名称</label>

                                <div class="col-md-3">
                                    <g:textField name="name" id="name" value="${this.opportunity?.name}" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">商机阶段</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="stage" id="stage" optionValue="name" value="${this.opportunity?.stage?.id}" optionKey="id" from="${com.next.OpportunityStage.findAllByActive(true)}" noSelection="${['': '请选择']}" />
                                </div>

                                <label class="col-md-2 col-form-label">商机类型</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="type" id="type" optionValue="name" optionKey="id" value="${this.opportunity?.type?.id}" from="${com.next.OpportunityType.list()}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>
                            <div class="form-group row">

                                <label class="col-md-2 col-form-label is-required">几率</label>

                                <div class="col-md-3">
                                    <div class="input-group">
                                        <g:textField name="probability" id="probability" value="${this.opportunity?.probability}" class="form-control" />
                                        <span class="input-group-addon">%</span>
                                    </div>

                                </div>

                                <label class="col-md-2 col-form-label is-required">金额</label>

                                <div class="col-md-3">
                                    <div class="input-group">
                                        <g:textField name="amount" id="amount" value="${this.opportunity?.amount}" class="form-control" />
                                        <span class="input-group-addon">元</span>
                                    </div>

                                </div>

                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">客户</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="account.id" value="${this.opportunity?.account?.id}" optionValue="account" optionKey="accountId" from="${com.next.AccountTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>
%{--
                                <label class="col-md-2 col-form-label">联系人</label>
                                <div class="col-md-3">
                                    <g:select class="form-control" name="contact.id" optionValue="contact" optionKey="contactId" from="${com.next.ContactTeam.findAllByUser(this?.user)}" value="${this.opportunity?.contact?.id}" noSelection="${['': '请选择']}" />
                                </div>
 --}%
                            </div>

                            <div class="form-group row">
%{--                                 <label class="col-md-2 col-form-label is-required">产品线</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="productLine" value="${this.opportunity?.productLine?.id}" id="productLine" optionKey="id" from="${com.next.ProductLine.list()}" noSelection="${['': '请选择']}" />
                                </div>
 --}%
                                <label class="col-md-2 col-form-label is-required">产品</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="product" value="${this.opportunity?.product?.id}" id="product" optionValue="name" optionKey="id" from="${com.next.Product.findAllByProductLine(this.opportunity?.productLine)}" />
                                </div>

                            </div>
                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">采购方法</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="purchasingMethod" value="${this.opportunity?.purchasingMethod?.id}" id="purchasingMethod" optionValue="name" optionKey="id" from="${com.next.PurchasingMethod.list()}" noSelection="${['': '请选择']}" />
                                </div>

                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">商机发现时间</label>

                                <div class="col-md-3 datePicker">
                                    %{-- <g:datePicker name="startTime" value="${this.opportunity?.startTime}" precision="minute" /> --}%
                                    <div class="input-group">
                                        <input type="text" valctrl="startTime" value="${this.opportunity?.startTime}" class="form-control form_datetime">
                                        <input type="hidden" id="startTime" name="startTime" value="date.struct">
                                        <input type="hidden" id="startTime_minute" name="startTime_minute" value="">
                                        <input type="hidden" id="startTime_hour" name="startTime_hour" value="">
                                        <input type="hidden" id="startTime_day" name="startTime_day" value="">
                                        <input type="hidden" id="startTime_month" name="startTime_month" value="">
                                        <input type="hidden" id="startTime_year" name="startTime_year" value="">
                                    </div>
                                </div>
                                <label class="col-md-2 col-form-label">客户预计采购时间</label>

                                <div class="col-md-3 datePicker">
                                    %{-- <g:datePicker name="endTime" value="${this.opportunity?.endTime}" precision="minute" /> --}%
                                    <div class="input-group ">
                                        <input type="text" valctrl="endTime" value="${this.opportunity?.endTime}" class="form-control form_datetime">
                                        <input type="hidden" id="endTime" name="endTime" value="date.struct">
                                        <input type="hidden" id="endTime_minute" name="endTime_minute" value="">
                                        <input type="hidden" id="endTime_hour" name="endTime_hour" value="">
                                        <input type="hidden" id="endTime_day" name="endTime_day" value="">
                                        <input type="hidden" id="endTime_month" name="endTime_month" value="">
                                        <input type="hidden" id="endTime_year" name="endTime_year" value="">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">来源</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="source" value="${this.opportunity?.source?.id}" id="source" optionValue="name" optionKey="id" from="${com.next.LeadSource.list()}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">状态</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="status" value="${this.opportunity?.status?.id}" id="status" optionValue="name" optionKey="id" from="${com.next.OpportunityStatus.list()}" noSelection="${['': '请选择']}" />
                                </div>
                                <label class="col-md-2 col-form-label">失败原因</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="causeOfFailure" value="${this.opportunity?.causeOfFailure?.id}" id="causeOfFailure" optionValue="name" optionKey="id" from="${com.next.CauseOfFailure.list()}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">商机描述</label>

                                <div class="col-md-8">
                                    <g:textArea rows="3" name="memo" id="memo" value="${this.opportunity?.memo}" class="form-control" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <div class="col-md-12">
                                    <g:submitButton class="btn btn-info" name="update" value="保存" />
                                </div>
                            </div>
                        </g:form>

                    </div>
                </div>
            </div>

        </div>
    </div>
</body>

</html>
